const { tabs } = require('./src/mock')
const bodyParser = require('body-parser')
module.exports = {
  devServer: {
    before(app) {
      app.use(bodyParser.json())

      app.get('/tabs', (req, res) => {
        res.send({
          code: 200,
          data: tabs
        })
      })

      app.post('/detail', (req, res) => {
        const { id } = req.body;
        // 第一层
        tabs.forEach(v => {
          // 第二层
          let o = v.children.find(item => item.id === id)
          if(o) {
            res.send({
              code: 200,
              data: o
            })
          }
        })
      })


    }
  }
}